fix(doc): apply redirects to git history at load time#655
Open
fix(doc): apply redirects to git history at load time#655
Conversation
Move the `GIT_HISTORY` static and `git_history()` accessor from `rari-types::globals` into a new `rari-doc::git_history` module. `HistoryEntry` stays in `rari-types`. Both existing call sites are already in `rari-doc`, so this is a pure relocation with no behavior change. Sets up a follow-up that needs to compose `git_history` with `rari-doc::redirects` at load time.
When `sync-translated-content` moves a translated doc to match an updated en-US slug, the move is local to the build environment and is never committed back to translated-content. As a result, the doc's new path has no entry in `_git_history.json`, the build pipeline's lookup misses, and the page footer shows `1970-01-01T00:00:00.000Z` for the last-modified date and an empty hash for the last-commit URL. Compose `git_history` with `redirects` at load time: for every `(old_url, new_url)` pair, if the corresponding old file path has a history entry and the new path doesn't, copy the entry under the new key. Entries that already exist at the new path (e.g. from a `content move` whose new location is committed) are preserved.
Contributor
|
1fd8fbe was deployed to: https://rari-pr655.review.mdn.allizom.net/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update
git_history, applying redirects at load time so moved pages resolve to a real history entry instead of the 1970-01-01 default.GIT_HISTORY/git_history()fromrari-typesto a newrari-doc::git_historymodule.(old_url, new_url)redirect, copy the old path's history entry to the new path (preserving any existing entry at the new path).Motivation
Prevent the build from falling back to 1970-01-01 for translated docs that
sync-translated-contentmoved locally during the build.Additional details
Related issues and pull requests
Fixes #247